﻿using System;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

using Ah.Testudin.Engine.Events;
using Ah.Testudin.Engine.Events.Components;
using Ah.Testudin.Engine.Graphics.Scenes.SceneNodes;
using Ah.Testudin.Engine.Graphics;
using Ah.Testudin.Engine.Graphics.Scenes;

namespace Ah.Testudin.Engine.Actors.Components.Render
{
    public class SpriteRenderComponent : IRenderComponent
    {
        #region Private Member Variables

        private readonly IEventManager _eventManager;

        #endregion

        #region Constructors

        public SpriteRenderComponent(
            Actor owner,
            RenderPass renderPass,
            Texture2D texture,
            Rectangle rectangle,
            IEventManager eventManager)
        {
            if (owner == null)
            {
                throw new ArgumentNullException("owner");
            }

            if (eventManager == null)
            {
                throw new ArgumentNullException("eventManager");
            }

            this.Owner = owner;

            _eventManager = eventManager;

            _eventManager.TriggerEvent(
                new RenderComponentCreatedEvent(
                    this.Owner.Id,
                    new SpriteSceneNode(
                        this.Owner.Id,
                        renderPass,
                        Matrix.Identity,
                        texture,
                        rectangle)));
        }

        #endregion

        #region IActorComponent

        public Actor Owner { get; private set; }

        public void Update(GameTime gameTime)
        {
        }

        public void Dispose()
        {
        }

        #endregion
    }
}
